Skip to content

feat(detectors/gcp): add parity for BMS, Cloud Run Worker Pool, GCE MIG, and GKE hostname - #9462

Open
dashpole wants to merge 13 commits into
open-telemetry:mainfrom
dashpole:gcp-detector-parity
Open

feat(detectors/gcp): add parity for BMS, Cloud Run Worker Pool, GCE MIG, and GKE hostname#9462
dashpole wants to merge 13 commits into
open-telemetry:mainfrom
dashpole:gcp-detector-parity

Conversation

@dashpole

@dashpole dashpole commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Part of #8946

Description

Brings feature parity to detectors/gcp to match the detector capabilities present in opentelemetry-collector-contrib's resourcedetectionprocessor:

  1. Bare Metal Solution (BMS): Check for Bare Metal Solution before the GCE metadata check, and emit BMS resource attributes (cloud.platform = "gcp_bare_metal_solution", cloud.account.id, host.name, cloud.region).
  2. Cloud Run Worker Pool: Handle CloudRunWorkerPool identically to CloudRun.
  3. GCE Managed Instance Group (MIG): Detect MIG attributes (gcp.gce.instance_group_manager.name, zone, region) on GCE.
  4. Best-effort GKE Hostname: Attempt to collect host.name on GKE nodes when available.

This is required for the collector to migrate to using this detector: open-telemetry/opentelemetry-collector-contrib#50211.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends detectors/gcp to match additional environment/resource-detection capabilities found in the Collector’s GCP resource detection, adding support for Bare Metal Solution (BMS) and Cloud Run Worker Pool parity, plus extra metadata on GCE and GKE.

Changes:

  • Add Bare Metal Solution (BMS) detection and emit BMS-specific resource attributes.
  • Treat CloudRunWorkerPool the same as CloudRun, and add best-effort host.name enrichment for GKE nodes.
  • Detect and emit GCE Managed Instance Group (MIG) attributes on GCE.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
detectors/gcp/types.go Extends the internal detector interface with MIG and BMS detection methods.
detectors/gcp/README.md Documents BMS as a supported detection environment.
detectors/gcp/detector.go Implements BMS short-circuit detection, Cloud Run Worker Pool handling, MIG attribute emission, and best-effort GKE hostname enrichment.
detectors/gcp/detector_test.go Adds/extends unit tests covering MIG, Cloud Run Worker Pool, BMS, and GKE hostname behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread detectors/gcp/detector.go
@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 84.5%. Comparing base (b876894) to head (147f2d6).

Files with missing lines Patch % Lines
detectors/gcp/detector.go 92.0% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@          Coverage Diff          @@
##            main   #9462   +/-   ##
=====================================
  Coverage   84.5%   84.5%           
=====================================
  Files        203     203           
  Lines      16805   16828   +23     
=====================================
+ Hits       14204   14225   +21     
- Misses      2121    2123    +2     
  Partials     480     480           
Files with missing lines Coverage Δ
detectors/gcp/detector.go 88.0% <92.0%> (+0.8%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dashpole
dashpole force-pushed the gcp-detector-parity branch from 338e8e2 to 6131435 Compare August 12, 2026 15:27
@ps-mir

ps-mir commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

@dashpole Does the scope also includes changes required for detector migration ?

#8946

If so, you can take the ownership of the task as well.

@dashpole

Copy link
Copy Markdown
Contributor Author

Ah, I forgot that issue existed. Sorry for taking it without asking.

@dashpole

Copy link
Copy Markdown
Contributor Author

I just need to add gcp.gce.instance.labels.* support, and move the library from opentelemetry-operations-go here.

@ps-mir

ps-mir commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Ah, I forgot that issue existed. Sorry for taking it without asking.

No issues :)

@dashpole
dashpole force-pushed the gcp-detector-parity branch from 091ecd6 to 6131435 Compare August 12, 2026 15:47
@dashpole

Copy link
Copy Markdown
Contributor Author

I just need to add gcp.gce.instance.labels.* support, and move the library from opentelemetry-operations-go here.

I'll do those as follow-ups

@dashpole
dashpole marked this pull request as ready for review August 12, 2026 16:00
@dashpole
dashpole requested a review from a team as a code owner August 12, 2026 16:00

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on error handling and semconv helpers in tests.

Comment thread detectors/gcp/README.md
Comment thread detectors/gcp/detector.go Outdated
Comment thread detectors/gcp/detector_test.go Outdated
Comment thread detectors/gcp/detector_test.go Outdated
Comment thread detectors/gcp/detector_test.go Outdated
Comment thread detectors/gcp/detector_test.go Outdated
@dashpole
dashpole force-pushed the gcp-detector-parity branch from 6131435 to e3989f3 Compare August 13, 2026 19:25

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small concern on CloudPlatform() being called twice for detection.

Comment thread detectors/gcp/detector.go Outdated
@dashpole
dashpole force-pushed the gcp-detector-parity branch from e3989f3 to 147f2d6 Compare August 14, 2026 13:42

@ps-mir ps-mir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants